<?php
/**
 * Created by PhpStorm.
 * User: zhangjian37
 * Date: 2016/8/24
 * Time: 17:32
 */

$RootDir = $_SERVER['DOCUMENT_ROOT'];
include $RootDir.'/utils/mysql/MysqlUtils.php';


//$phone=$_POST['phone']; //手机号码
//$check=$_POST['check']; //验证码
//$username=$_POST['username']; //用户名
//$password=$_POST['password']; //密码
//$ip=$_POST['ip']; //ip
//$mac=$_POST['mac']; //mac

$phone=""; //手机号码
$check=""; //验证码
$username=""; //用户名
$password=""; //密码
$ip=""; //ip
$mac=""; //mac

$conn = conn_mysql();
//判断手机号码是否使用
$query = "select 1 from user where phone_num = '$phone' limit 1";
$result = queryRecord($query,$conn);
echo mysql_num_rows($result);
if(mysql_num_rows($result)>=1) die("Error: 手机号码已经被占用");

//判断验证码是否正确
$query = "select 1 from phone_check where phone = '$phone' and check_info = '$check' limit 1";
$result = queryRecord($query,$conn);
if(mysql_num_rows($result)>=1) die("Error: 验证码不对");

//判断用户名是否已经使用
$query = "select 1 from user where uname = '$username' limit 1";
$result = queryRecord($query,$conn);
if(mysql_num_rows($result)>=1) die("Error: 用户名已经被占用");

$user_id = "";
//保存信息
$query = "insert into user (user_id,uname,pwd,phone_num,mac,ip) VALUES ('$user_id','$username','$password','$phone','$mac','$ip')";
if (!mysql_query($query,$con))
{
    die('Error: ' . mysql_error());
}

echo $user_id;

mysql_close($conn);